package com.example.catalog.controller;

import com.example.catalog.entity.Car;
import com.example.catalog.entity.User;
import com.example.catalog.enums.CarTypeEnum;
import com.example.catalog.mapper.CarMapper;
import com.example.catalog.mapper.UserMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description 枚举转换器Controller
 */
@RestController
@RequestMapping("/enums")
public class EnumHadlerController {

    @Resource
    private CarMapper carMapper;

    /**
     * @description 枚举转换： 数据库 --> java实体
     */
    @RequestMapping("/all")
    public List<Car> query() {
        return carMapper.selectAll();
    }

    /**
     * @description 枚举转换： java实体  --> 数据库
     */
    @RequestMapping("/add")
    public String add() {
        Car car = new Car();
        car.setId("2");
        car.setCarName("测试");
        car.setCarType(CarTypeEnum.BM);
        carMapper.insertSelective(car);
        return "true";
    }

}
